package com.lishe.lishe.lishe.module.myorder.adapter;


import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lishe.lishe.R;
import com.lishe.lishe.lishe.MyRecyclerView.RecyclerviewBaseAdapter;
import com.lishe.lishe.lishe.module.myorder.activity.CourierActivity;
import com.lishe.lishe.lishe.module.myorder.bean.LogisticsObject;

import java.util.LinkedList;

/**
 * Created by shino on 2017/10/22.
 */

public class LogisticsAdapter extends RecyclerView.Adapter<LogisticsAdapter.LogisticsHolder> {
    private Activity context;
    private LinkedList<LogisticsObject> list;

    public LogisticsAdapter(Activity context, LinkedList<LogisticsObject> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public LogisticsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_activity_logistics, null);
        return new LogisticsHolder(view);
    }

    @Override
    public void onBindViewHolder(LogisticsHolder holder, int position) {
        final LogisticsObject logistics = list.get(position);
        holder.logistics_name.setText(logistics.getLogi_name()+"：");
        holder.logistics_id.setText(logistics.getLogi_id());
        holder.content.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CourierActivity.jump(context,logistics.getSteps());
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class LogisticsHolder extends RecyclerView.ViewHolder {
        private TextView logistics_name;
        private TextView logistics_id;
        private LinearLayout content;

        public LogisticsHolder(View v) {
            super(v);
            logistics_name = v.findViewById(R.id.logistics_name);
            logistics_id = v.findViewById(R.id.logistics_id);
            content=v.findViewById(R.id.content);

        }
    }
}
